package com.school.service.impl;

import com.school.entity.AdminUser;
import com.school.entity.Carousel;
import com.school.mapper.AdminUserMapper;
import com.school.service.AdminUserService;
import com.school.util.MD5Util;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class AdminUserServiceImpl implements AdminUserService {
    @Resource
    AdminUserMapper adminUserMapper;
    @Override
    public AdminUser login(String userName, String password) {
        String md5Password = MD5Util.MD5Encode(password, "UTF-8");
        return adminUserMapper.findByUserNameAndPassword(userName, md5Password);
    }
    @Override
    public AdminUser getUserDetailById(Integer userId) {
        return adminUserMapper.selectById(userId);
    }
    @Override
    public int updateName(Integer userId, String loginUserName, String nickName) {
        AdminUser adminUser = adminUserMapper.selectById(userId);
        if (adminUser != null) {
            adminUser.setLoginUserName(loginUserName);
            adminUser.setNickName(nickName);
        }
        return adminUserMapper.updateById(adminUser);
    }
}